import tkinter
from tkinter import ttk
class MainWindow():
    def __init__(self):
        self.root=tkinter.Tk()
        self.root.minsize(500,500)
        self.root.geometry('500x500+0+0')

    def add_frame(self):
        frame = ttk.Frame(self.root)
        frame.grid(row=3,column=4)
        botton = ttk.Button(frame, text='logen',command=self.command1)
        botton.grid(row=4,column=3)
        self.username = tkinter.StringVar()
        name = ttk.Entry(frame, textvariable=self.username)
        name.grid(row=2,column=3)
        self.userpwd = tkinter.StringVar()
        pwd= ttk.Entry(frame, textvariable=self.userpwd)
        pwd.grid(row=3, column=3)

    def command1(self):
        n = self.username.get()
        p = self.userpwd.get()
        if n == 'lv' and p == '123456':
            print('登陆成功')
        else:
            self.username.set("")
            self.userpwd.set("")
            print('登陆的密码或者用户名错误')


    def mainloop(self):
        self.root.mainloop()

MW = MainWindow()
MW.add_frame()
MW.mainloop()

